<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="format-detection" content="telephone=no">
	<title>摇一摇</title>
    <link rel="stylesheet" href="<?php echo TEMPLATE_SITE_URL;?>/css/animate.min.css">
        <link rel="stylesheet" href="<?php echo TEMPLATE_SITE_URL;?>/css/yao.css">
	<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.js"></script>
    <script src="<?php echo RESOURCE_SITE_URL;?>/js/wow.min.js"></script>
    <script>
	if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){
			new WOW().init();
		};
	</script>
</head>

<body>


<div id="contentbox">

<div class="cover" style="display: none;">
	<div class="coverItem">
	  <dl class="category">
	  	<!-- <dd ><img src="<?php echo TEMPLATE_SITE_URL;?>/images/sortIcon01.jpg"><p>全部推荐</p></dd> -->
		<?php if(!empty($output['categorylist'])){?>
		<?php $i = 1;?>
		<?php foreach($output['categorylist'] as $val){?>
		<dd <?php if($output['cid'] == $val['id']){ echo 'class="on"';}?> cid="<?php echo $val['id'];?>">
		<img src="<?php echo TEMPLATE_SITE_URL;?>/images/category/sortIcon<?php echo $i;?>.png">
		<p><?php echo $val['categoryname'];?></p>
		</dd>
		<?php $i++;?>
		<?php }?>
		<?php }?>
		<!-- <dd><img src="<?php echo TEMPLATE_SITE_URL;?>/images/sortIcon08.jpg"><p>其他品类</p></dd>  -->
		
	  </dl>
	</div>
</div>
  <div class="shakeTitle">
     <a class="totalLink"><?php echo $output['category']['categoryname'];?>(<span class="cishu"><?php echo $output['yao_count'];?></span>/<?php echo count($output['list']);?>)</a><a class="sort">选择分类</a>  </div>
     
     		<?php if(!empty($output['list'])){?>
     		<?php $iii = 0;?>
     		<input type="hidden" name="auctionnum" value="<?php echo $iii;?>">
     		<input type="hidden" name="seller_id" value="<?php echo $output['list'][0]['seller_id'];?>">
     		<input type="hidden" name="auction_id" value="<?php echo $output['list'][0]['id'];?>">
     		<?php foreach($output['list'] as $val){?>
			<div class="dowebok box" seller_id="<?php echo $val['seller_id']?>" aid="a<?php echo $iii;?>" auction_id="<?php echo $val['id']?>" style="<?php if($iii!=0){ echo 'display:none;';}?>" >
				<div class="item4 wow  fadeInDown">	
				  <?php if($iii == 0){?>		
				  <div class="shakeTip" style="display:none;"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/shakeTip.png"></div>	
				  <?php }?>	  
				  <div class="boxTop">
					<div class="boxProfile"><img src="<?php echo $val['avatar'];?>"></div>
					<h2 style="height:25px;">
						<?php if($val['is_company']==1){?>
							<?php if($val['is_company_type']==1){?>
								<span class="certify"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/verifyFinished_business.png" width="26" height="20"></span>						
							<?php }else{?>
								<span class="certify"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/verifyFinished_individual.png" width="26" height="20"></span>						
							<?php }?>
						<?php }?>   
						<span class="levels <?php echo $val['level'];?>"></span>
						<span class="sellerName"><?php echo $val['nickname'];?></span>
					</h2>
										
					<p><?php echo $val['signature']?></p>
					<!-- <span class="score">评分：4.82分</span> -->
					
				  </div>
				  <div class="shakeImg">
					<div class="shakeImgLeft"><a href="index.php?act=index&auction_id=<?php echo $val['id'];?>&type=yao">
<div style="background-repeat:none;background-position:center;background-size:cover;background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$val['auction_add_date'].'/'.$val['auction_img1'];?>)"></div></a><a href="index.php?act=index&auction_id=<?php echo $val['id'];?>&type=yao">
<div style="background-repeat:none;background-position:center;background-size:cover;background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$val['auction_add_date'].'/'.$val['auction_img1'];?>)"></div></a>
					</div>
					<a href="index.php?act=index&auction_id=<?php echo $val['id'];?>&type=yao">
<div class="shakeImgRight" style="background-repeat:none;background-position:center;background-size:cover;background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$val['auction_add_date'].'/'.$val['auction_img1'];?>)"></div></a>
				  </div>
				  <div class="describ">
				  	<?php if($val['freeship']==1){?>
				  	<img src="<?php echo TEMPLATE_SITE_URL;?>/images/post.jpg" width="40" height="20">
				  	<?php }?>
                  	<?php echo bearshop_auction_description_substr($val['auction_description']);?>
                  </div>
				  <div class="popBottom">
					<span class="hot"><?php echo $val['viewnum'];?></span><span class="price">当前竞拍价：<em>￥<?php echo $val['leadingprice'];?></em></span>
				  </div>
			</div>
		  </div>  
		  <?php $iii++;?>
		  <?php }?>
		  <?php }?>

  <div class="shakeBn"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/shakeBn.png" width="70" height="70"></div>             
  <div class="fixBar">
     <a class="access" href="javascript:;">进入店铺</a><a class="my" href="index.php?act=index&op=yaolist">我摇到的</a>
  </div>                  
</div>

<script type="text/javascript">

$(function(){

	var auction_id = parseInt($('input[name=auction_id]').val());
	if(auction_id>0){
		var count = parseInt('<?php echo count($output['list'])?>');
		var cishu = parseInt($('.cishu').html());
		if(cishu >= count){

			$("div[aid=a0]").show();
			$(".shakeTip").show();
		}else{
			$.ajax({
				type:'get',
				url:'index.php?act=index&op=addyao',
				data:{auction_id:auction_id},
				dataType:'json',
				success:function(data){
					if(data.state == '1'){
						$('.cishu').html(eval(cishu+1));
					}
					return false;	
				}
			});
		}
	}
	
	$('.shakeTip').click(function(){
		$('.cover').show();
	});
	
	$('.sort').click(function(){
		$('.cover').show();
	});

	$('.category dd').click(function(){
		var cid = $(this).attr('cid');
		location.href = 'index.php?act=index&op=yao&cid='+cid;
	});
	
	$('.shakeBn').click(function(){
		var aid = parseInt($('input[name=auctionnum]').val());
		$("div[aid=a"+aid+"]").hide();
		
		var number = eval(aid+1);
		var count = parseInt('<?php echo count($output['list'])?>');
		var cishu = parseInt($('.cishu').html());

		if(cishu >= count){
			$("div[aid=a0]").show();
			$(".shakeTip").show();
			return false;
		}
		
		if(number>count){
			$("div[aid=a0]").show();
			$(".shakeTip").show();
			return false;
		}

		$('.cishu').html(eval(cishu+1));
		$('input[name=auctionnum]').val(number);
		$("div[aid=a"+number+"]").show();

		//添加摇过拍品
		var auction_id = $("div[aid=a"+number+"]").attr('auction_id');
		$.ajax({
			type:'get',
			url:'index.php?act=index&op=addyao',
			data:{auction_id:auction_id},
			dataType:'json',
			success:function(){
				return false;
			}
		});
		
		var seller_id = $("div[aid=a"+number+"]").attr('seller_id');
		$('input[name=seller_id]').val(seller_id);		
		
		return false;
	});

	$('.access').click(function(){
		var seller_id = parseInt($('input[name=seller_id]').val());
		if(seller_id>0){
			location.href = 'index.php?act=index&seller_id='+seller_id;
		}
		
		return false;
	});
	
	if (window.DeviceMotionEvent) {
		//获取移动速度，得到device移动时相对之前某个时间的差值比
		window.addEventListener('devicemotion', deviceMotionHandler, false);
	}else{
		alert('您好，你目前所用的设置好像不支持重力感应哦！');
	}

	//设置临界值,这个值可根据自己的需求进行设定，默认就3000也差不多了
	var shakeThreshold = 6000;
	//设置最后更新时间，用于对比
	var lastUpdate     = 0;
	//设置位置速率
	var curShakeX=curShakeY=curShakeZ=lastShakeX=lastShakeY=lastShakeZ=0;
	
	function deviceMotionHandler(event){

		//获得重力加速
		var acceleration =event.accelerationIncludingGravity;

		//获得当前时间戳
		var curTime = new Date().getTime();

		if ((curTime - lastUpdate)> 100) {

			//时间差
			var diffTime = curTime -lastUpdate;
				lastUpdate = curTime;


			//x轴加速度
			curShakeX = acceleration.x;
			//y轴加速度
			curShakeY = acceleration.y;
			//z轴加速度
			curShakeZ = acceleration.z;

			var speed = Math.abs(curShakeX + curShakeY + curShakeZ - lastShakeX - lastShakeY - lastShakeZ) / diffTime * 10000;

			if (speed > shakeThreshold) {
				//TODO 相关方法，比如：

				//播放动画
				var aid = parseInt($('input[name=auctionnum]').val());
				$("div[aid=a"+aid+"]").hide();
				
				var number = eval(aid+1);
				var count = parseInt('<?php echo count($output['list'])?>');
				var cishu = parseInt($('.cishu').html());

				if(cishu >= count){
					$("div[aid=a0]").show();
					$(".shakeTip").show();
					return false;
				}
				
				if(number>count){
					$("div[aid=a0]").show();
					$(".shakeTip").show();
					return false;
				}
				
				//播放音效
				shakeAudio.play();
				
				$('.cishu').html(eval(cishu+1));
				$('input[name=auctionnum]').val(number);
				$("div[aid=a"+number+"]").show();

				//添加摇过拍品
				var auction_id = $("div[aid=a"+number+"]").attr('auction_id');
				$.ajax({
					type:'get',
					url:'index.php?act=index&op=addyao',
					data:{auction_id:auction_id},
					dataType:'json',
					success:function(){
						return false;
					}
				});
				
				var seller_id = $("div[aid=a"+number+"]").attr('seller_id');
				$('input[name=seller_id]').val(seller_id);		
				
				return false;
			}

			lastShakeX = curShakeX;
			lastShakeY = curShakeY;
			lastShakeZ = curShakeZ;
		}
	}

	//预加摇一摇声音
	var shakeAudio = new Audio();
	    shakeAudio.src = '<?php echo TEMPLATE_SITE_URL;?>/images/shake_sound.mp3';
	var shake_options = {
	    preload  : 'auto'
	}
	for(var key in shake_options){
	    if(shake_options.hasOwnProperty(key) && (key in shakeAudio)){
	        shakeAudio[key] = shake_options[key];
	    }
	}
});

</script>

</body>
</html>